<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/views/common/include/taglib.jsp"%>

<script src="${ctx}/js/controllers/goods/GoodsInfoListController.js" type="text/javascript"></script>
<div style="top: 130px; position: fixed; height: 30px; font-size: 14px; font-family: '微软雅黑'; margin-left: -236px;">当前位置：${sessionScope.currcent_position}</div>
<section>
    <section>
        <!--begin 搜索栏 -->
        <input id="goodsType" type="hidden" value="${goodsType }">
        <div class="panel" style="margin-top: 23px;">
            <div class="forword_area"></div>
            <div class="location">商品管理</div>
            <div class="serach-box">
                <div class="btn-group">
                    <input id="selectFirstLevel" type="hidden" value="${firstLevel}"> <select class="dropdown-menu" id="firstLevel" onchange="changeCategory(this);">
                        <option value="" <c:if test="${firstLevel == null }">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;分类</option>
                        <c:forEach items="${firstCategories}" var="item" varStatus="cStatus">
                            <option value="${item.id}" <c:if test="${item.id == firstLevel}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;${item.name}</option>
                        </c:forEach>
                    </select>
                </div>
                <div id="secondId" class="btn-group" style="display: none;">
                    <input id="selectSecondLevel" type="hidden" value="${secondLevel}"> <select id="secondLevel" class="dropdown-menu">
                    </select>
                </div>
                <div style="float: left; margin-left: 20px; width: 215px;">
                    <span style="font-family: '微软雅黑'; font-size: 14px; color: #919191;">价格</span> <input id="minFilter" style="width: 35%;" title="最低价" maxlength="6"
                        value="<c:if test="${min!=-1}">${min}</c:if>" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');" class="input-sm" placeholder="最低价"> <span style="color: #919191;">-</span>
                    <input id="maxFilter" style="width: 35%;" title="最高价" maxlength="8" value="<c:if test="${max!=-1}">${max}</c:if>" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');"
                        class="input-sm" placeholder="最高价">
                </div>
                <div id="searchBox" style="float: left; margin-left: 20px;">
                    <input id="name" style="width: 300px; float: left;" type="text" maxlength="20" value="${(not empty name)? name : ''  }" class="input-sm" placeholder="关键字搜索">
                    <button class="search" style="border: 1px solid #FFAA00;" onclick="getGoodsInfoList();">
                        <img src="${ctx }/images/seller/goods/search.png" style="margin-left: 18px; margin-top: 5px;">
                    </button>
                </div>

            </div>
        </div>
        <!--end 搜索栏 -->

        <div>
            <table class="table">
                <thead>
                    <tr>
                        <th width="25%">商品信息</th>
                        <th width="10%">库存</th>
                        <th width="10%">销量</th>
                        <th width="10%">创建时间</th>
                        <th width="10%">更新时间</th>
                        <th width="10%">推荐指数</th>
                        <th width="25%">操作</th>
                    </tr>
                </thead>

                <tbody id="tableTbody">
                    <c:if test="${not empty goodsInfo.list }">
                        <c:forEach items="${goodsInfo.list }" var="goods" varStatus="status">
                            <tr>
                                <td>
                                    <div style="float: left; margin-left: 21px;">
                                        <c:if test="${ not empty goods.logo}">
                                            <img width="70px" height="70px" src="${sessionScope.image_logo}${goods.logo}" />
                                        </c:if>
                                        <c:if test="${ empty goods.logo}">
                                            <img width="70px" height="70px" src="${ctx}/images/seller/common/defaultgoods.jpg" />
                                        </c:if>
                                    </div>
                                    <div class="desc" style="margin-left: 52px; vertical-align: middle;">
                                        <p>${goods.name}</p>
                                        <p>价格￥${goods.price}</p>
                                    </div>
                                </td>
                                <td>${goods.stock}</td>
                                <td>${goods.sales}</td>
                                <td>${goods.sendTime}</td>
                                <td>${goods.updateTime}</td>
                                <td>${goods.isRecommend}</td>
                                <td><a class="fa fa-check " title="详情" onclick="showDetail(${goods.id});">详情</a> 
                                    <span>&nbsp;—</span> 
                                    <a class="fa fa-check " title="编辑" onclick="saveOrUpdate(${goods.id});">编辑</a> <span>&nbsp;—</span> <c:if test="${goods.state == 1 }">
                                    <a class="fa fa-check " onclick="updateState(${goods.id},'${goods.state }');">上架</a>
                                    </c:if> <c:if test="${goods.state == 0 }">
                                        <a class="fa fa-check " onclick="updateState(${goods.id},'${goods.state }');">下架</a>
                                    </c:if> <span>&nbsp;—</span> <a class="fa fa-check " title="置顶" onclick="updateRecommond(${goods.id});">置顶</a></td>
                            </tr>
                        </c:forEach>
                    </c:if>
                </tbody>

                <tfoot>
                    <tr>
                        <td colspan="8">
                            <div>
                                <div style="float: right; margin-top: 48px; font-family: '微软雅黑'">
                                    <div style="float: left;">
                                        <ul class="footer_ul">
                                            <c:if test="${goodsInfo.hasPreviousPage }">
                                                <li onclick="gotoPage(${currentPage-1 });"><a class="leftRight">&lt;&lt;</a></li>
                                            </c:if>
                                            <c:if test="${goodsInfo.firstPage > 1}">
                                                <li onclick="gotoPage(1);" style="border: 1px solid #9A9A9A;"><a>1</a></li>
                                                <c:if test="${goodsInfo.firstPage > 2}">
				                        		...
				                        	</c:if>
                                            </c:if>
                                            <c:forEach items="${goodsInfo.navigatepageNums }" var="page">
                                                <li onclick="gotoPage(${page });" class="<c:if test="${currentPage == page }">active</c:if>" style="border: 1px solid #9A9A9A;"><a>${page}</a></li>
                                            </c:forEach>
                                            <c:if test="${goodsInfo.lastPage < goodsInfo.pages}">
                                                <c:if test="${goodsInfo.firstPage < goodsInfo.pages - 1}">
				                        		...
				                        	</c:if>
                                                <li onclick="gotoPage(${goodsInfo.pages});" style="border: 1px solid #9A9A9A;"><a>${goodsInfo.pages}</a></li>
                                            </c:if>
                                            <c:if test="${goodsInfo.hasNextPage }">
                                                <li><a onclick="gotoPage(${currentPage+1});" class="leftRight">&gt;&gt;</a></li>
                                            </c:if>
                                        </ul>
                                    </div>
                                    <div style="float: left; height: 28px; line-height: 28px;">
                                        <span style="color: #9A9A9A;">跳转到</span> <input class="inputclass" id="pageNo" onkeydown="if(event.keyCode==13){event.keyCode=0;return false;}" type="text"
                                            value="${currentPage }" style="width: 26px; height: 26px" onkeyup="checInputNum(this)"> <span style="color: #9A9A9A;">页</span> <span
                                            class="buttonclass" id="J_JumpTo" onclick="gotoGoodsInfoPage(null);"><a>GO</a></span>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </section>
</section>

<script type="text/javascript">
		var ctx = '${ctx}';
		setCtx(ctx);
		
		//实现选中取消切换图片
		$("tbody td>img").toggle(function(){    
		    $(this).attr("src","${ctx }/images/tables/honggou.png"); 
		    //$(this).parents("tr").children().each(function(){
			   // $(this).css("background","#D3F0F1");
		   //});    
		},function(){    
		    $(this).attr("src", "${ctx }/images/tables/wugou.png"); 
		    //$(this).parents("tr").children().each(function(){
			    //$(this).css("background","");
		   //});
		    });
		    
		//实现全选切换所有选项图标
		$("#all").toggle(function(){    
		    $(this).attr("src","${ctx }/images/tables/honggou.png"); 
		    $("tbody td>img").attr("src","${ctx }/images/tables/honggou.png");  
		},function(){    
		    $(this).attr("src", "${ctx }/images/tables/wugou.png"); 
		    $("tbody td>img").attr("src","${ctx }/images/tables/wugou.png");  
		    });
		
	</script>
<!-- 解决ie 6 7 8 9不能显示placeholder的问题 -->
<script src="${ctx}/js/lib/jquery.JPlaceholder.js"></script>
